Ext.onReady(function(){
	Ext.QuickTips.init();//要表单验证错误后提示错误信息，  需加上这行
	Ext.form.Field.prototype.msgTarget = 'side';
	//加上上面那行代码，有错误时会在输入框侧面显示一个感叹号，鼠标移上去会显示错误信息，反之是鼠标移到到输入框就显示错误信息
	//自动引入js文件     ps.要判断文件是否重复引入
	var includeObj=function(obj){
		var script=document.getElementsByTagName(script);
        var script = document.createElement("SCRIPT");
        script.setAttribute("type","text/javascript");
        script.setAttribute("src","./Js/"+obj+".js");
        var head = document.head;
        head.appendChild(script);
		console.log(script);
	};
	//主面板
	var viewport=new Ext.Viewport({
		layout:'border',
		items: [
		    {
				region:"north",    
				title:'留言板管理',
				padding:"1"
		    },
		    {
				xtype:'treepanel',
				title:'导航菜单',
				width:250,
				region:"west",
				collapsible:true,			
				listeners:{
					click:function(node,rowIndex){	
						 var value=node.attributes.value;
						 var id=node.attributes.id;
						 var centerPanel=Ext.getCmp("index_center_region"); 
						 includeObj(value);
						 setTimeout(function(){
							// Fn.log(1);
							 var panel=Ext.getCmp(id);
							 if(typeof panel==="undefined"){
								 var obj=null;
								 eval('obj=new '+value+'()');//eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码。
								// alert(panel);
								// Fn.log(2);
								 centerPanel.add(obj.panel);
								 obj.panel.show(); 
							 }else{
								 panel.show();
							 }
						 },20);
					}
				},
				root:{
			 	    expanded: true,                                                              
	                children:[{ 
			            text: "用户管理",
		                expanded: true,
		                children: [
		                    {text: "用户列表",id:'Sys-userList',value:'userList',leaf: true},
		                   // {text: "用户信息",id:"userInfo", value:'userInfo', leaf: true}
		                ]	 
			         },{text: "帖子管理", 
	                    expanded: true ,                                   
	                    children:[ 
                            { text: "留言列表",id:"Sys-msgList",value:"msgList", leaf: true }
	                        //{ text: "添加留言",id:"msgAdd", value:"msgAdd",leaf: true} 
	                    ]
	                }]
	            },
	            rootVisible : false
		    },
		    {
		    	xtype:"panel",
		    	region:"center",
		    	padding:"1",
		    	layout:"fit",
		    	items:[{
		    		xtype:'tabpanel',
				 	id:"index_center_region",
				 	items:[{
				 		title:'默认'	,
				 		html:"留言板"
				 	}]
		      }]
		   }
		]
	});		
})